package com.ybwh.springboot2.minio.utils;


import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MinioUtils {


    /**
     * 创建存储的对象名
     *
     * @param path     存储路径
     * @param fileName 文件名称
     * @param hashcode 文件的hashcode
     * @return
     */
    public static String createObjectName(String path, String fileName, String hashcode) {

        int i = fileName.lastIndexOf('.');
        String extName = fileName.substring(i);
        StringBuilder objName = new StringBuilder(path);

        if (!path.endsWith("/")) {
            objName.append("/");
        }

        objName.append(fileName.substring(0, fileName.length())).append("_").append(hashcode).append(extName);

        return objName.toString();
    }

    public static void main(String[] args) {
        System.out.println(createObjectName("/ewrw/", "rere.hbm.xml", "53552525425424"));
    }


}
